import { ItemData } from "../../../resource/info/ItemData";
import { PetMingItemData } from "../../pet/info/PetMingItemData";
import { ItemsUtil } from "../../shortcuts/item/ItemsUtil";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { ColorConfig } from "../../../resource/ColorConfig";
import { ObjCreate } from "../ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { Language } from "../../../../../extend/language/Language";
import { GTextFormat } from "../../../../common/GTextFormat";
import { FontUtil } from "../../../../common/font/FontUtil";
import { ParamsConst } from "../../../../common/global/ParamsConst";
import { ProxyType } from "../../../../common/global/ProxyType";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { TItem } from "../../../../../Message/Db/Tables/TItem";
import { ItemExInfo } from "../../../resource/info/ItemExInfo";
type int = number;
//class PetLifeStyleTooltip
    
    export  class PetLifeStyleTooltip /* flash.display.Sprite */
    {
        constructor()
        {
            
            this.init();
            return;
        }

        public /* override */ get width(): number
        {
            return 200;
        }

        public set data(arg1: ItemData)
        {
            this._mingItemData = arg1 as PetMingItemData;
            this._tItem = this._mingItemData.itemInfo.item;
            this.resort();
            return;
        }

        /* internal  */resort(): void
        {
            this._currentY = 0;
            this._nameTxt.htmlText = ItemsUtil.getItemName(this._mingItemData) + HTMLUtil.addColor("  Lv" + this._mingItemData.lsLevel, ColorConfig.instance.getItemColorString(this._mingItemData.color));
            this._currentY = this._currentY + (this._nameTxt.height + 10);
            if (this._mingItemData.isExpLifeStyle) 
            {
                if (this._attrTxt && this.contains(this._attrTxt)) 
                {
                    this.removeChild(this._attrTxt);
                }
                if (this._nextAttrTxt && this.contains(this._nextAttrTxt)) 
                {
                    this.removeChild(this._nextAttrTxt);
                }
            }
            else 
            {
                if (!this._attrTxt) 
                {
                    this._attrTxt = ObjCreate.createGTextField("", this._leftX, 0, 220, 30, null, GlobalStyle.textFormat6);
                    this._attrTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
                }
                this._attrTxt.htmlText = "<textFormat leading=\'5\'>" + this._mingItemData.getAttrDesc() + "</textFormat>";
                this._attrTxt.y = this._currentY;
                if (!this.contains(this._attrTxt)) 
                {
                    this.addChild(this._attrTxt);
                }
                this._currentY = this._currentY + (this._attrTxt.height + 5);
                if (this._mingItemData.isShowNext && !this._mingItemData.isMax) 
                {
                    if (!this._nextAttrTxt) 
                    {
                        this._nextAttrTxt = ObjCreate.createGTextField("", this._leftX, 0, 220, 30, null, GlobalStyle.textFormat6);
                        this._nextAttrTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
                    }
                    this._nextAttrTxt.htmlText = "<textFormat leading=\'5\'><font color=\'#00ff00\'>" + Language.getString(54754) + "</font>\n" + this._mingItemData.getAttrDesc("\n", true) + "</textFormat>";
                    this._nextAttrTxt.y = this._currentY;
                    if (!this.contains(this._nextAttrTxt)) 
                    {
                        this.addChild(this._nextAttrTxt);
                    }
                    this._currentY = this._currentY + (this._nextAttrTxt.height + 5);
                }
                else if (this._nextAttrTxt && this.contains(this._nextAttrTxt)) 
                {
                    this.removeChild(this._nextAttrTxt);
                }
            }
            this._expTxt.y = this._currentY;
            if (this._mingItemData.isExpLifeStyle) 
            {
                this._expTxt.htmlText = Language.getString(54756) + this._mingItemData.effect;
            }
            else 
            {
                this._expStr = Language.getString(54755) + this._mingItemData.lsExp;
                if (!this._mingItemData.isMax) 
                {
                    this._expStr = this._expStr + ("/" + this._mingItemData.upgradeExp);
                }
                this._expTxt.htmlText = this._expStr;
            }
            this._currentY = this._currentY + (this._expTxt.height + 5);
            this._eatTxt.y = this._currentY;
            this._eatTxt.htmlText = Language.getString(54789) + (this._mingItemData.effect + this._mingItemData.lsExp);
            return;
        }

        public init(): void
        {
            this._nameTxt = ObjCreate.createGTextField("", this._leftX, 0, 220, 30, this, new GTextFormat(FontUtil.songtiName, 14, null, true, null, null, null, null, "center"));
            this._nameTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._expTxt = ObjCreate.createGTextField("", this._leftX, 0, 220, 20, this, GlobalStyle.textFormat6);
            this._expTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            this._eatTxt = ObjCreate.createGTextField("", this._leftX, 0, 220, 20, this, GlobalStyle.textFormat6);
            this._eatTxt.autoSize = flash.text.TextFieldAutoSize.LEFT;
            return;
        }

        public getNameText(): string
        {
            var loc3=null;
            var loc4=null;
            var loc1="";
            var loc2="";
            if (this._tItem) 
            {
                loc1 = this._tItem.name;
                loc3 = ColorConfig.instance.getItem("item", this._tItem.color.toString());
                if (loc3) 
                {
                    loc2 = loc3.color;
                }
            }
            if (ParamsConst.instance.proxyType == ProxyType.TW && !(ParamsConst.instance.gameName == null)) 
            {
                if (loc1.indexOf(ParamsConst.instance.gameName) >= 0) 
                {
                    loc4 = new RegExp(ParamsConst.instance.gameName, "g");
                    loc1 = loc1.replace(loc4, "");
                }
            }
            return HTMLUtil.addColor(loc1, loc2);
        }

        public dispose(): void
        {
            return;
        }

        /* internal */ /* var */_nameTxt: GTextFiled;

        /* internal */ /* var */_attrTxt: GTextFiled;

        /* internal */ /* var */_nextAttrTxt: GTextFiled;

        /* internal */ /* var */_expTxt: GTextFiled;

        /* internal */ /* var */_eatTxt: GTextFiled;

        /* internal */ /* var */_mingItemData: PetMingItemData;

        /* internal */ /* var */_tItem: TItem;

        /* internal */ /* var */_itemExInfo: ItemExInfo;

        /* internal */ /* var */_leftX: int=10;

        /* internal */ /* var */_currentY: int;

        /* internal */ /* var */_expStr: string;
    }
